<?php
$userId = strtolower($email);
$currentUser = BUser::find(array('userId' => $userId));

if($currentUser != NULL) {
    $sentMailMsg = "An Email has been sent to ".$email.
            " with an activation key. Please check your mail to complete registration.";

    $activationKey = $currentUser->myid;
    $regUrl = Yii::app()->createAbsoluteUrl('site/activate', array('activationKey' => $activationKey, 'email' => $email));
    $message = "<br /><br />Following link just for debug, MUST REMOVE in registerMail.php !<br /><br />"
            . "<html><body>Please click below link to activate your account.<br />".
                "<a href=".$regUrl."/>"."Activate account: ".$email." now!"."</a><br /><br />Thank you.</body></html>";
    echo $message;
    
    //following code is for release, comment out for debug.
//    echo $sentMailMsg;
//    
//    ##Send activation Email
//    $to      = $email;
//    $subject = "www.billyn.net用户帐号激活"; //"www.billyn.net Registration";
//    $message = "亲爱的用户：<br/>感谢您在我站www.billyn.net注册了新帐号。<br/>请点击链接激活您的帐号。<br/><br/>"
////            ."Welcome to our website!<br/><br/>You, or someone using your email address, has completed registration "
////            . "at www.billyn.net. ". "You can complete registration by clicking the following link:<br/><br/>"
//            . $regUrl
//            ."<br/>如果此次激活请求非你本人所发，请忽略本邮件。"
////            . "<br/><br/>If this is an error, ignore this email and you will be removed from our mailing list."
//            . "<br/><br/>"
//            ."此致"
////            ."Regards,"
//            ."<br/> www.billyn.net Team";
//
//    $headers = 'From: noreply@billyn.net' . "\r\n" .
//
//        'Reply-To: noreply@billyn.net' . "\r\n" .
//
//        'X-Mailer: PHP/' . phpversion();
//
//    mail($to, $subject, $message, $headers);
}
else
    echo "<html><body>Account ".$email." not existed!</body></html>";
?>